package AcademicUI;

import java.io.*;
import java.net.Socket;



public class Client {
    private Socket socket;
    private static PrintWriter writer;
      static BufferedReader reader; 
    private static String message;
    
    public static void main(String[]args){
    	Client client=new Client();
          	client.start();
    	    UserLogin login=new UserLogin();
        	login.JFrame();
    }
    
    private void start(){
    	try{
    	    socket=new Socket("127.0.0.1",3000);
    		writer=new PrintWriter(socket.getOutputStream());
    		InputStreamReader stream=new InputStreamReader(socket.getInputStream());
    		reader=new BufferedReader(stream);
    	}catch(IOException e){
    		System.out.println(e);
    	}
    }
    
     public static void sendMessage(String message){
    	try{
    		writer.println(message);
    		writer.flush();
    	}catch(Exception e){
    		System.out.println(e);
    	}
    }
    
     public static String receiveMessage(){
    	while(message==null){
    	try {
			message=reader.readLine();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	}
    	String result=message;
    	message=null;
    	   return result;
   
    }
    
}
    
    
  

